package com.ds.client.screen;

import com.badlogic.gdx.Game;
import com.ds.client.support.ServerStub;
import com.ds.support.GameInfo;

/**
 * game class, used to maintain whole game life cycle
 */
public class InitGame extends Game {

	int myID = -1;
	ChooseScreen chooseScreen;
	RaceScreen raceScreen;
	StartScreen startScreen;
	WaitingScreen waitingScreen;
	WinScreen winScreen;
	LoseScreen loseScreen;
	GameInfo gameInfo;
	LoseConnScreen loseConnScreen;

	@Override
	public void create() {
		chooseScreen = new ChooseScreen(this);
		startScreen = new StartScreen(this);
		waitingScreen = new WaitingScreen(this);
		winScreen = new WinScreen(this);
		loseScreen = new LoseScreen(this);
		loseConnScreen = new LoseConnScreen(this);

		super.setScreen(startScreen);
	}

	public RaceScreen getRaceScreen() {
		return new RaceScreen(this);
	}
	
	public ChooseScreen getChooseScreen(){
		return new ChooseScreen(this);
	}
	
	public WaitingScreen getWaitingScreen(){
		return new WaitingScreen(this);
	}
	
	public LoseConnScreen getLoseConnScreen(){
		return new LoseConnScreen(this);
	} 
	
	public WinScreen getWinScreen(){
		return new WinScreen(this);
	}
	
	public LoseScreen getLoseScreen(){
		return new LoseScreen(this);
	}
	
	/**
	 * Quit games 
	 */
	@Override
	public void dispose() {
		if (myID != -1) {
			try {
				ServerStub serverStub = new ServerStub();
				// remove the car info from server
				serverStub.removeMyself(myID);
			} catch (Exception e) {
				System.exit(0);
			}
		}
		System.exit(0);
	}

}
